package com.home.component.managedbean;

import java.io.Serializable;
import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import com.home.model.dto.CityDto;
import com.home.model.dto.DistrictDto;
import com.home.model.service.CityService;

@ManagedBean(name = "accountComponentBean")
@RequestScoped
public class AccountComponentManagedBean implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private List<DistrictDto> districts;
	private List<CityDto> cities;
	
	
	@EJB
	private CityService cityService;
	
	/**
	 * init data
	 */
	public void initData() {
		cities = cityService.findAllCities();
	}
	
	/**
	 * process event change city
	 * @param cityDto
	 */
	public void changeCity(CityDto cityDto) {
		districts = cityDto.getDistricts();
	}
	
	public List<DistrictDto> getDistricts() {
		return districts;
	}

	public void setDistricts(List<DistrictDto> districts) {
		this.districts = districts;
	}

	public List<CityDto> getCities() {
		return cities;
	}

	public void setCities(List<CityDto> cities) {
		this.cities = cities;
	}
	
	
}
